<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Basic Form - jQuery EasyUI Demo</title>
    <link rel="stylesheet" type="text/css" href="static/jquery-easyui/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="static/jquery-easyui/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="static/jquery-easyui/demo/demo.css" />
    <script type="text/javascript" src="static/jquery-easyui/jquery.min.js"></script>
    <script type="text/javascript" src="static/jquery-easyui/jquery.easyui.min.js"></script>
    <style type="text/css">
        .login {
            position: absolute;
            left: 50%;
            top: 50%;
            margin: -100px 0 0 -100px;
        }
    </style>
</head>
<body>
    <div class="login">
        <div class="easyui-panel" title="登录框" style="width:100%;max-width:400px;padding:30px 60px;left: 50%">
            <div>
                <div style="margin-bottom:20px">
                    <input class="easyui-textbox" id="username" name="username" style="width:100%" data-options="label:'用户名:',required:true">
                </div>
                <div style="margin-bottom:20px">
                    <input class="easyui-textbox" id="password" name="password" type="password" style="width:100%" data-options="label:'密码:',required:true">
                </div>
            </div>
            <div style="text-align:center;padding:5px 0">
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">登录</a>
            </div>
        </div>
    </div>
    <script>
        function submitForm(){
            var username = $("#username").val();
            var password = $("#password").val();
            var para = {
                'username' : username,
                'password' : password
            }
            $.ajax({
                url: "${request.contextPath }/doLogin",
                data: para,
                type: "POST",
                dataType: "json",
                success: function (data) {
                    //data为json对象集合，所以此处用[0]
                    window.location.href = "${request.contextPath }/index.html";
                }
            });
        }
        function clearForm(){
            $('#ff').form('clear');
        }
    </script>
</body>
</html>